#include <iostream>

using namespace std;

const int N = 1e3 + 10;

int q[N][N], s[N][N];
int n, m;

int main(void)
{
    int k;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            scanf("%d", &q[i][j]);
            s[i + 1][j + 1] = q[i][j] + s[i + 1][j] + s[i][j + 1] - s[i][j];
        }

    int x1, y1, x2, y2;
    for (int i = 0; i < k; i++)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        cout << s[x2][y2] - s[x2][y1 - 1] - s[x1 - 1][y2] + s[x1 - 1][y1 - 1] << endl;
    }
}